package com.apadog.study.ai;

public class Test {

    public static void main(String[] args) {
        int[] arr = {9,-9}; // 示例数组

        Integer max = null;
        Integer secondMax = null;

        for (int num : arr) {
            if (max == null || num > max) {
                secondMax = max;
                max = num;
            } else if ((secondMax == null || num > secondMax) && num < max) {
                secondMax = num;
            }
        }

        if (secondMax != null) {
            System.out.println("第二大值是: " + secondMax);
        } else {
            System.out.println("没有找到第二大值（数组中可能所有元素都相同或不足两个不同值）");
        }
    }

}
